

<?php		
echo $javascript->codeBlock("
	hs.transitions = ['expand', 'crossfade'];
	hs.outlineType = 'rounded-white';
	hs.fadeInOut = true;
	//hs.dimmingOpacity = 0.75;
	
	// Add the controlbar
	hs.addSlideshow({
		slideshowGroup: 'group1',
		interval: 5000,
		repeat: false,
		useControls: true,
		fixedControls: 'fit',
		overlayOptions: {
			opacity: 0.75,
			position: 'bottom center',
			hideOnMouseOut: true
		}
	});
",$options = array('allowCache'=>false,'safe'=>false,'inline'=>false));
?>

<div class="content">
	<div id="left-column">
		<?php echo $this->element('left_column')?>		
	</div>

	<div class="right-store-column search-bg">
		<?php echo $this->element('search_more',array('plugin'=>'store'))?>
	</div>
		
	<div class="right-store-column">						
		<div class="storeProducts view">
		<?php echo $this->Form->create('StoreProduct',array('url'=>array('plugin'=>'store','controller'=>'carts','action'=>'cart_add')));?>
		<?php 
			$ilosc_column = count($storeProductTypes);
			//jesli nie usluga
			if(!$storeProduct['StoreProduct']['service']){
				foreach ($storeProductTypes as $group => $types) {	
					$hidden = ($ilosc_column == 1 && count($types) == 1 ) ? true : false;
					if($hidden) break;
				}
			}else{
				$hidden = true;
			}
		?>	
		
		<h2><?php echo $storeProduct['StoreProduct']['name']; ?></h2>
		<table width="100%" cellpadding="10" cellspacing="0">
			<tr>
				<td class="gallery" width="50%" valign="top">
					
					<table class="index" cellspacing="1" cellpadding="10"><tr>
						<th align="left"><?php echo __d('store','Serial No:',true)?></th>
						<th align="left"><?php echo $storeProduct['StoreProduct']['serial_number']?></th>
					</tr></table>
					
					<div class="highslide-gallery">
					<a href="<?php echo $fileUpload->image($storeProduct['StoreUpload']['name'],array('autoResize'=>false,'imagePathOnly'=>true));?>"  title="<?php echo $storeProduct['StoreProduct']['name']?>" style="background: #ffffff url(<?php echo str_replace(' ',"%20",$fileUpload->image($storeProduct['StoreUpload']['name'],array('autoResize'=>true,'width'=>100,'imagePathOnly'=>true)));?>) center no-repeat;" class="highslide"  onclick="return hs.expand(this)"></a>
					<?php foreach ($storeProduct['StoreUpload'] as $key => $img) {
						if(is_array($img) && !empty($img)){?>
							<a href="<?php echo $fileUpload->image($img['name'],array('autoResize'=>false,'imagePathOnly'=>true));?>" class="highslide" title="<?php echo $storeProduct['StoreProduct']['name']?>" style="background: #ffffff url(<?php echo str_replace(' ',"%20",$fileUpload->image($img['name'],array('autoResize'=>true,'width'=>100,'imagePathOnly'=>true)));?>) center no-repeat;" class="highslide"  onclick="return hs.expand(this)"></a>							
					<?php }}?>
					</div>
					

					
					<table width="100%" cellspacing="1" cellpadding="10">
						<tr>
							<td valign="middle" align="left">
								<div class="view-price">
								    <?php if( $storeProduct['StoreProduct']['price_promocja'] > 0){?>
											<span class="product-view-price"><?php echo $this->Store->price($storeProduct['StoreProduct']['price_promocja'],2,'',null,$storeProduct['StoreProduct']['currency_id'],$storeProduct['StoreCurrency']['exchange'])?></span> 
											<br/>
											<span class="product-view-price-discount"><?php echo $this->Store->price($storeProduct['StoreProduct']['price_detaliczna'],2,'',null,$storeProduct['StoreProduct']['currency_id'],$storeProduct['StoreCurrency']['exchange']);?></span>
									<?php }else{?>
											<span class="product-view-price"><?php echo $this->Store->price($storeProduct['StoreProduct']['price_detaliczna'],2,'',null,$storeProduct['StoreProduct']['currency_id'],$storeProduct['StoreCurrency']['exchange'])?></span>
									<?php }?>	
									
									<?php echo (!empty($storeProduct['StoreUnit']['name'])) ? ' / '.$storeProduct['StoreUnit']['name'] : '';?>
									
								</div>									
							</td>
							<td valign="middle" align="right">
								<input type="image" src="/img/store.moon/buttons_order.png" style="border: none; padding: 0px; margin: 0px;" />								
							</td>
						</tr>
					</table>
					
					
					
				</td>
				<td width="50%" valign="top">											
						<?php if($ilosc_column != 0 || $storeProduct['StoreProduct']['service']){?>
							
								<?php echo $this->Form->hidden('StoreProduct.id',array('value'=>$storeProduct['StoreProduct']['id']));?>
								<?php $j=0; ?> 
	
								<?php 
								if($hidden){
									foreach ($storeProductTypes as $group => $types) {
										foreach ($types as $key => $type) {
											// gdy jeden typ
											echo $this->Form->hidden('StoreType.'.$type['id'].'.id',array('value'=>$type['id']));
											echo $this->Form->hidden('StoreType.'.$type['id'].'.name',array('value'=>$type['name']));
											echo $this->Form->hidden('StoreType.'.$type['id'].'.amount',array('value'=>1));
											$group_name = (isset($storeTypeGroup[$group])) ? $storeTypeGroup[$group] : null;
											echo $this->Form->hidden('StoreType.'.$type['id'].'.group',array('value'=>$group_name));
										}
										echo $this->Form->hidden("StoreTypeGroup.{$group}.id",array('value'=>$type['id']));
										
									}
								}else{
								?>							
								<table class="index" cellspacing="1" cellpadding="10"><tr>
								<?php 		
								foreach ($storeProductTypes as $group => $types) {	
//									$hidden = ($ilosc_column == 1 && count($types) == 1 ) ? true : false;
									$header = (isset($storeTypeGroup[$group])) ? $storeTypeGroup[$group] : '&nbsp;';
									echo "<th  align=\"left\"  valign=\"top\">{$header}</th>"; 	
								}?>	
								</tr>
								<tr>
								<?php foreach ($storeProductTypes as $group => $types) {?>
									<td align="left" valign="top">
									
									<?php						
										$types_options = array();
										foreach ($types as $key => $type) {
									?>
									<div>					
										<?php
											// gdy wiecej typow
											//echo $this->Form->checkbox('StoreType.'.$type['id'].'.id',array('value'=>$type['id'],'style'=>'float: left;'));
											//echo '&nbsp; '.$type['name']; 
											$types_options[$type['id']]=$type['name']; 
											echo $this->Form->hidden('StoreType.'.$type['id'].'.id',array('value'=>$type['id']));
											echo $this->Form->hidden('StoreType.'.$type['id'].'.name',array('value'=>$type['name']));
											echo $this->Form->hidden('StoreType.'.$type['id'].'.amount',array('value'=>1));
											$group_name = (isset($storeTypeGroup[$group])) ? $storeTypeGroup[$group] : null;
											echo $this->Form->hidden('StoreType.'.$type['id'].'.group',array('value'=>$group_name));
										?>									
									</div>
									<?php }
										echo $this->Form->input("StoreTypeGroup.{$group}.id",array('options'=>$types_options,'label'=>false));
									?>
										
									</td>	
								<?php }?>								
								</tr>
								</table>						
								<?php }?>
					   			
					   		
					    <?php }else if(!$storeProduct['StoreProduct']['service']){?>
					    	<div class="clr"></div>	
					    	<br/>
					    	<div class="store-view-stan-zerowy"><?php echo __d('store','Availability: Off Stock',true)?></div>							
						<?php }?>
						
						<?php if(!empty($storeProduct['StoreProduct']['www'])){?>
							<?php echo $html->link($storeProduct['StoreProduct']['www'],$storeProduct['StoreProduct']['www']) ?>
						<?php }?>
						
						<?php if(!empty($storeProduct['StoreProduct']['content'])){?>
							<?php echo $storeProduct['StoreProduct']['content']; ?>
						<?php }?>
					</td>		

				</tr>
			</table>
			<?php echo $this->Form->end();?>
		</div>
		<div class="clr"></div>
	</div>
	
	<?php if(is_array($storeMatchProducts) && !empty($storeMatchProducts)){?>
	<div class="right-store-column">
		<div class="storeProducts view">
			<h2 class="_50 float-left"><?php __d('store','Matching Jewellery');?></h2>	
			<table class="index" cellpadding="0" cellspacing="0">
			<tr>
					<th>&nbsp;</th>
					<th><?php __d('store','Offer Type');?></th>
					<th><?php __d('store','Category');?></th>
					<th><?php __d('store','Name');?></th>
					<th><?php __d('store','Price');?></th>
					<?php if($session->check('Auth.User.id')){?><th class="actions"><?php __d('store','Actions');?></th><?php }?>
			</tr>
			<?php
			$i = 0;
			foreach ($storeMatchProducts as $storeProduct):
				$class = null;
				if ($i++ % 2 == 0) {
					$class = ' class="altrow"';
				}
			?>
			<tr<?php echo $class;?>>
				<td valign="middle" align="left">
					<?php echo $this->Html->link($fileUpload->image($storeProduct['StoreProduct']['StoreUpload']['name'],array('autoResize'=>true,'width'=>100,'imagePathOnly'=>false))
						, array('action' => 'view', $storeProduct['StoreProduct']['id']),array('escape'=>false)); ?>&nbsp;
				</td>
				<td valign="top" align="left">
					<?php 
						if(isset($storeProduct['StoreProduct']['StoreModel']) && is_array($storeProduct['StoreProduct']['StoreModel'])){
							foreach ($storeProduct['StoreProduct']['StoreModel'] as $key_model => $model) {
								echo $model['name'].'<br/>';
							}
						}
					?>&nbsp;
				</td>		
				<td align="left" valign="top">
					<?php 
						if(is_array($storeProduct['StoreProduct']['StoreCategory']) && !empty($storeProduct['StoreProduct']['StoreCategory'])){
							foreach ($storeProduct['StoreProduct']['StoreCategory'] as $cat_key => $category) {
								echo $category['name'].'<br/>';
							}
						}
					?>
				&nbsp;</td>		
				<td align="left" valign="top" ><?php echo $storeProduct['StoreProduct']['name']; ?>&nbsp;</td>
				<td align="right">
					<?php if( $storeProduct['StoreProduct']['price_promocja'] > 0){?>							
							<span class="product-view-price-discount"><?php echo $this->Store->price($storeProduct['StoreProduct']['price_detaliczna'],2,'','',$storeProduct['StoreProduct']['currency_id'],$storeProduct['StoreProduct']['StoreCurrency']['exchange']);?></span>
							<br/>
							<span class="product-view-price"><?php echo $this->Store->price($storeProduct['StoreProduct']['price_promocja'],2,'',null,$storeProduct['StoreProduct']['currency_id'],$storeProduct['StoreProduct']['StoreCurrency']['exchange'])?></span>							
					<?php }else{?>
							<span class="product-view-price"><?php echo $this->Store->price($storeProduct['StoreProduct']['price_detaliczna'],2,'',null,$storeProduct['StoreProduct']['currency_id'],$storeProduct['StoreProduct']['StoreCurrency']['exchange'])?></span>
					<?php }?>	
					<br/>
					<?php echo $html->link($html->image(HOST.'/see_more.png'), 
				        array('plugin'=>'store','controller'=>'products','action' => 'view', $storeProduct['StoreProduct']['id'],Inflector::slug($storeProduct['StoreProduct']['name'],'-')),
				        array('escape'=>false)); ?>					
				</td>
				<?php if($session->check('Auth.User.id')){?>
				<td class="actions" align="center" valign="middle">
					<?php echo $this->Html->link($html->image('firma/actions_16_delete.png',array('title'=>__d("store","View",true))), array('plugin'=>'store','controller'=>'products','action'=>'delete_match',$this->data['StoreProduct']['id'], $storeProduct['StoreProduct']['id']), array('escape'=>false), sprintf(__d('store','Are you sure you want to delete # %s?', true), $storeProduct['StoreProduct']['name'])); ?>
				</td>
				<?php }?>
			</tr>
			<?php endforeach; ?>
			</table>
		</div>
	</div>
	<?php }?>
</div>



<?php if($session->check('Auth.User.id')){?>
<?php echo $this->element('toolbar_actions_main',array('plugin'=>'store','toolbar'=>'product'))?>
<?php }?>